﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAL;
using System.Threading;
using System.Collections;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;


namespace BLL
{
    public class InitChromo
    {
        //create random tour for path representation
        public void createPathTour(ref PathTour tour, int numOfCity, Random ran)
        {           
            int[] tourTemp = new int[numOfCity];
            for (int i = 1; i <= numOfCity; i++)
            {
                tourTemp[i - 1] = i;
            }
            int count = numOfCity;
            int pos = 0;
            for (int i = 0; i < numOfCity - 2; i++)
            {
                pos = ran.Next(count);
                tour.OrderCity[i] = tourTemp[pos];
                for (int j = pos; j < count - 1; j++)
                {
                    tourTemp[j] = tourTemp[j + 1];
                }
                count--;
            }
            tour.OrderCity[numOfCity - 1] = tourTemp[1];
            tour.OrderCity[numOfCity - 2] = tourTemp[0];
        }
    }
}
